package com.xiyou.luckdraw.web.controller;

import com.xiyou.luckdraw.api.dto.user.CountNewVoucherResponse;
import com.xiyou.luckdraw.api.dto.user.UserInfoListResponse;
import com.xiyou.luckdraw.api.dto.user.UserTntegralLogListRequest;
import com.xiyou.luckdraw.api.dto.user.UserTntegralLogListResponse;
import com.xiyou.luckdraw.api.service.IUserTntegralLogService;
import com.xiyou.luckdraw.common.constants.ResultCodeConstants;
import com.xiyou.luckdraw.common.result.ResponseData;
import com.xiyou.luckdraw.common.result.ResponseUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: UserTntegralLogController
 * @Description: 用户兑换券记录
 * @author: limingxing
 * @Date: 2019-10-23 15:50
 */
@RestController
@RequestMapping("/coupon")
@Api(value = "用户兑换券Controller", tags = {"用户兑换券记录接口"})
public class UserTntegralLogController {

    @Autowired
    private IUserTntegralLogService userTntegralLogService;


    @ApiOperation(value = "用户兑换券列表")
    @PostMapping("/list")
    public ResponseData<UserTntegralLogListResponse> list(@RequestBody UserTntegralLogListRequest request) {
        UserTntegralLogListResponse response = userTntegralLogService.getList(request);
        if (response.getCode().equals(ResultCodeConstants.SUCCESS.getCode())) {
            return new ResponseUtils().setData(response);
        }
        return new ResponseUtils().setData(response.getMsg());
    }



    @ApiOperation(value = "统计一周用户新增券数")
    @PostMapping("/getCountNewVoucher")
    public ResponseData<CountNewVoucherResponse> getCountNewVoucher() {
        CountNewVoucherResponse response = userTntegralLogService.selectCountNewVoucher();
        if (response.getCode().equals(ResultCodeConstants.SUCCESS.getCode())) {
            return new ResponseUtils().setData(response);
        }
        return new ResponseUtils().setData(response.getMsg());
    }

}
